﻿@using Resource;
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    @{ await Html.RenderPartialAsync("/Views/Shared/_LayoutScript.cshtml"); }
    @{ await Html.RenderPartialAsync("/Views/Shared/_StyleCss.cshtml"); }

    <link href="/css/MachineSum.css?v=@DateTime.Now.Ticks" rel="stylesheet" />
    <style>
        .ZebraNo {
            color: black;
            background-color: #e8f1f9;
        }

        .ZebraTo {
            color: black;
            background-color: #ffffff;
        }

        .note {
            color: red;
            font-size: 0.15rem;
            font-weight: bolder;
        }

        .devicedetailt {
            color: black;
            border: 1px solid #007297;
            margin-top: 16.5%;
            position: absolute;
            top: -28%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 999;
            display: none;
            width: 100.2%;
            height: 112%;
            text-align: center;
            padding: 0.12rem;
            background-color: #fff;
            border-radius: 0.1rem;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        .tester_hour {
            float: left;
        }

        #myTable {
            color: black !important;
        }

        /*table滚动条*/
        #tester_table {
            color: black;
            font-size: 0.125rem;
            height: 9.32rem;
            overflow-y: auto;
        }

        table {
            color: black;
            width: 100%;
            border-collapse: collapse;
            /*table-layout: fixed;*/
        }

        thead {
            color: black;
            text-align: center;
            margin: auto;
            /*height: 0.2rem;*/
            position: sticky;
            top: 0;
            background-color: #a2c2e2;
            /*#a1e1e1;*/
        }

        thead > tr {
            color: black;
            font-size: 0.13rem;
            height: 0.5rem;
        }

        th, td {
            color: black;
            padding: 0.05rem;
            /*border: 1px solid #0aa9cd;*/
            border: 1px solid #c2c3c4;
        }

        tfoot {
            font-size: 0.13rem;
            position: sticky;
            bottom: 0;
            background-color: #a2c2e2; /*#a1e1e1*/
            /* height: 0.45rem;*/
        }

        tbody:hover .zebracro {
            color: black;
            background-color: #164362;
        }

        .tabletd {
            color: black;
            text-align: center;
        }

        .chart {
            color: black;
            padding: 0.2rem 0.2rem;
            border-top: none;
            width: 100%;
            height: 4.7rem;
        }

    </style>
    <title>DayOuput</title>
</head>
<body class="fill-parent" style="overflow-y: hidden">
    <div class="main">
        <div class="header">
            <div class="header-left fl">
                <img src="/images/logo.png?v=@DateTime.Now.Ticks" class="scaled-image" draggable="false" oncontextmenu="return false;" ondragstart="return false;" />
            </div>
            <div class="quer">
                <spn>
                    <div id="query">
                        <select id="cmb_classtype">
                            <option value="OTD">@Label.OTD</option>
                            <option value="YTD">@Label.YTD</option>
                        </select>
                        <select id="cmb_area_type" name="AreaType" placeholder="select area">
                            <option value="DG">@Label.DG</option>
                            <option value="AMT">@Label.AMT</option>
                        </select>
                        <select id="cmb_prod_type" name="ProdType" placeholder="select prodtype">
                            <option value="ALL">@Label.ALL</option>
                            <option value="Normal">@Label.Fresh</option>
                            <option value="Rework">@Label.Rework</option>
                        </select>
                        <select id="cmb_proj_code">
                            @*
                            <option value="NCCSAC">NCCSAC</option>
                            <option value="NCCSA6">NCCSA6</option>
                            <option value="OCCSAA">OCCSAA</option>
                            <option value="OCCSAN">OCCSAN</option>
                            <option value="NCCSAD2">NCCSAD2</option>
                            <option value="NCCSA3">NCCSA3</option>
                            <option value="OCCSAM">OCCSAM</option>
                            <option value="NCCSAM">OCCSAM</option>
                            <option value="OCCSAJ">OCCSAJ</option>
                            <option value="OCCSBA">OCCSBA</option>
                            <option value="NCCSAP2">NCCSAP2</option>
                            <option value="GC1">GC1</option>
                            *@
                        </select>
                    </div>
                </spn>
            </div>
            <div class="btn">
                <spn>
                    <div id="query">
                        <div class="dropdown">
                            <button class="dropbtn">@Label.Desktop</button>
                            <div class="dropdown-content">
                                <a class="menudropdown" href=@Html.Raw($"https://dashboard.li.lumentuminc.net/API/DesktopApp/Dashboard.exe?v={DateTime.Now.Ticks}") download>@Label.Local</a>
                                <a class="menudropdown" href=@Html.Raw($"https://dashboard.li.lumentuminc.net/API/DesktopApp/Dashboard_lnk.zip?v={DateTime.Now.Ticks}") download>@Label.Shortcut</a>
                            </div>
                        </div>
                        <div class="dropdown">
                            <button class="dropbtn">@Label.Data@Label.Datum</button>
                            <div class="dropdown-content">
                                <a id="btn_query" class="menudropdown" onclick="TestDataExport('TestData')">@Label.Data@Label.Export</a>
                            </div>
                        </div>
                        <div class="dropdown">
                            <button class="dropbtn">@Label.Language</button>
                            <div class="dropdown-content">
                                <a class="menudropdown" onclick="setLanguageCookie('@Const.CNLANGUAGE')">@Label.Chinese</a>
                                <a class="menudropdown" onclick="setLanguageCookie('@Const.USLANGUAGE')">@Label.English</a>
                            </div>
                        </div>
                        <button class="modalBtn dimension">@Label.Full</button>
                    </div>
                </spn>
            </div>
            <div class="header-center fl">
                <div class="header-title"></div>
                <div class="header-img"></div>
            </div>
            <div class="header-right fl" id="time"></div>
            <div class="header-bottom fl"></div>
        </div>
        <div class="center">
            <div class="center-left fl">
                <div class="left-top rightTop border">
                    <div class="title">@Label.Device@Label.OTD@Label.Capacity</div>
                    <div class="chart" id="Tab1"></div>
                </div>
                <div class="left-bottom rightTop border">
                    <div class="title">@Label.Device@Label.Hour@Label.Output</div>
                    <div class="chart" id="Tab2"></div>
                </div>
            </div>
            <div class="center-right fr">
                <div class="right-top rightTop border">
                    <div class="title">@Label.CouplingSuccessRate</div>
                    <div class="chart" id="Tab3"></div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" href="?v=@DateTime.Now.Ticks">
        //模板初始化配置
        $('#cmb_classtype').prop('selectedIndex', 0);
        $("#cmb_area_type").prop('selectedIndex', 0);
        $("#cmb_prod_type").prop('selectedIndex', 0);
        //$('#cmb_proj_code').prop('selectedIndex', 1);
        //$('#cmb_proj_code').val('NCCSAD').trigger('change');
        $(document).ready(function () {
            var whei = $(window).height();
            $("html").css({ fontSize: whei / 12.5 });
            $(window).resize(function () {
                if ($(".dimension").text() == "@Html.Raw(Label.Full)") {
                    var whei = $(window).height();
                    $("html").css({ fontSize: whei / 12.5 });
                }
                else {
                    var whei = $(window).width();
                    $("html").css({ fontSize: whei / 22 })
                }
            });
            /*当前时间*/
            function numberToUpperCase(number) {
                var uppercaseMonths = [
                    '一月', '二月', '三月', '四月', '五月', '六月',
                    '七月', '八月', '九月', '十月', '十一月', '十二月'
                ];
                return uppercaseMonths[number - 1];
            }
            var myDate = new Date();
            var result = numberToUpperCase(myDate.getMonth() + 1);
            $('.header-title').html("@Html.Raw(Label.Board_DeviceCapacity)");
            function getTime() {
                var myDate = new Date();
                var myYear = myDate.getFullYear(); //年
                var myMonth = myDate.getMonth() + 1; //月
                var myToday = myDate.getDate(); //日
                var myDay = myDate.getDay(); //星期
                var myHour = myDate.getHours(); //小时
                var myMinute = myDate.getMinutes(); //分钟
                var mySecond = myDate.getSeconds(); //秒数
                var week = ['@Label.Sunday', '@Label.Monday', '@Label.Tuesday', '@Label.Wednesday', '@Label.Thursday', '@Label.Friday', '@Label.Saturday'];
                var nowTime;

                nowTime = myYear + '-' + fillZero(myMonth) + '-' + fillZero(myToday) + '&nbsp;&nbsp;' + fillZero(myHour) + ':' + fillZero(myMinute) + ':' + fillZero(mySecond) + '&nbsp;&nbsp;' + week[myDay] + '&nbsp;&nbsp;';
                $('#time').html(nowTime);
            };
            function fillZero(str) {
                var realNum;
                if (str < 10) {
                    realNum = '0' + str;
                } else {
                    realNum = str;
                }
                return realNum;
            }
            setInterval(getTime, 1000);

            // 设置全屏
            $('.dimension').on('click', function (e) {
                var element = document.documentElement;
                if ($(".dimension").text() == "@Html.Raw(Label.Full)") {
                    // 判断浏览器设备类型
                    if (element.requestFullscreen) {
                        element.requestFullscreen();
                    } else if (element.mozRequestFullScreen) {       //兼容火狐
                        element.mozRequestFullScreen();
                    } else if (element.webkitRequestFullscreen) {    //兼容谷歌
                        element.webkitRequestFullscreen();
                    } else if (element.msRequestFullscreen) {        //兼容IE
                        element.msRequestFullscreen();
                    }
                    $(".dimension").text("@Html.Raw(Label.Exit+Label.Full)");
                } else {
                    if (document.exitFullscreen) {
                        document.exitFullscreen();
                    } else if (document.mozCancelFullScreen) {
                        document.mozCancelFullScreen();
                    } else if (document.webkitCancelFullScreen) {
                        document.webkitCancelFullScreen();
                    } else if (document.msExitFullscreen) {
                        document.msExitFullscreen();
                    }
                    $(".dimension").text("@Html.Raw(Label.Full)");
                }
            });
            $('#Tab2').mouseleave(function () {
                $("#operatorhouroutput").css("display", "none");
            })
        });

        $(document).on('change', '#cmb_classtype', function () {
            var classtype = $(this).val();
            if (classtype) {
                var headerTitle;
                if (classtype == "OTD") {
                    $(".soe").show();
                    headerTitle = `OTD @Html.Raw(Label.Board_DeviceCapacity)`;
                    $("div.title").attr("title", function () {
                        return $(this).text($(this).text().replace("@Html.Raw(Label.YTD)", "@Html.Raw(Label.OTD)"));
                    });
                } else if (classtype == "YTD") {
                    $(".soe").hide(); $(".soe").addClass("hidden");
                    headerTitle = `YTD @Html.Raw(Label.Board_DeviceCapacity)`;
                    $("div.title").attr("title", function () {
                        return $(this).text($(this).text().replace("@Html.Raw(Label.OTD)", "@Html.Raw(Label.YTD)"));
                    });
                }
                $('.header-title').html(headerTitle);
            }
        });
        //定时
        var Tabtimer;
        function TabInterval() {
            clearInterval(Tabtimer);
            //每隔5m执行一次
            Tabtimer = setInterval(function () {
                Query();
                echartsautomatic();
            }, 10 * 60 * 1000);
        }

        //图表自适应大小
        var chartIds = ['Tab1', 'Tab2', 'Tab3'];
        function echartsautomatic() {
            var charts = [];
            chartIds.forEach(function (chartId) {
                var chart = echarts.init(document.getElementById(chartId));
                charts.push(chart);
            });
            window.onresize = function () {
                charts.forEach(function (chart) {
                    chart.resize();
                });
            };
        }

        $(window).on('resize', function () {
            echartsautomatic();
        });

        //cmb_proj_code
        $(function () {
            var projcodeSelect = $('#cmb_proj_code');
            $.ajax({
                //url: 'http://localhost:44304/ReportAction/GetProjCode',
                url: api + '/ReportAction/GetProjCode',
                type: 'POST',
                async: false,
                success: function (data) {
                    populateSelect(projcodeSelect, data.ReturnData, false);
                }
            });
        });

        function populateSelect(select, data, defaultOptionText) {
            select.empty();
            if (defaultOptionText) {
                select.append($('<option>', {
                    value: null,
                    text: '请选择产品'
                }));
            }
            else {
                select.append($('<option>', {
                    value: 'ALL',
                    text: 'ALL'
                }));
            }
            $.each(data, function (key, value) {
                select.append($('<option>', {
                    value: value.value,
                    text: value.text
                }));
            });
            $('#cmb_proj_code').val('NCCSAD')
            //$('#cmb_proj_code').prop('selectedIndex', 1);
            Query();
        }

        $(document).on('change', '#cmb_classtype,#cmb_area_type,#cmb_prod_type,#cmb_proj_code', function () {
            Query();
        });

        function makeAjaxRequest(url, data) {
            return new Promise(function (resolve, reject) {
                $.ajax({
                    type: "POST",
                    url: api + url,
                    data: data,
                    async: false,
                    dataType: "json",
                    success: function (data) {
                        resolve(data.ReturnData);
                    },
                    error: function (xhr, status, error) {
                        reject(error);
                    }
                });
            });
        }

        var Tab = {};
        function GetToDayMachineCapacity() {
            var header_key = {
                cl_type: $('#cmb_classtype').val(),
                area: $('#cmb_area_type').val()
            };
            var pam = {};
            pam.type = $('#cmb_prod_type').val();
            pam.proj_code = $('#cmb_proj_code').val();
            pam.header_key = JSON.stringify(header_key);
            return makeAjaxRequest("/ReportAction/DeviceProd", pam);
        }
        //查询所有
        var Query = function () {
            Promise.all([GetToDayMachineCapacity()])
                .then(function (data) {
                    Tab.Tab1 = data[0].Table;
                    Tab.Tab2 = data[0].Table1;
                    Tab.Tab3 = data[0].Table2;
                    GetToDayMachineCapacityChart();
                    GetMachineHourOutputChart();
                    GetCouplingSuccessRateChart();
                    echartsautomatic();
                })
                .catch(function (error) {
                });
            TabInterval();
        }

        /*导出生产数据*/
        var TestDataExport = function (type) {
            $('#btn_query').prop('disabled', true);
            ExportType = type;
            var formData = new FormData();
            formData.append('type', ExportType);
            formData.append('prodtype', $('#cmb_prod_type').val());
            formData.append('proj_code', $('#cmb_proj_code').val());
            formData.append('area', $('#cmb_area_type').val());
            var url = api + "/ReportAction/GetTestDateExport";
            PostExportToExcel(url, formData);
            alert("数据量过大。。。\n\n正在加速下载，请等待2分钟^_^");
        }

        //POST 参数不固定 导出
        var PostExportToExcel = function (url, formData) {
            //GET: var url = "http://localhost:44304/Dashboard/ExportToExcel?" + $.param(pam);
            var xhr = new XMLHttpRequest();
            xhr.open('POST', url, true);
            xhr.responseType = 'blob';
            xhr.onload = function () {
                if (xhr.status === 200) {
                    $('#btn_query').prop('disabled', false);
                    var url = window.URL.createObjectURL(xhr.response);
                    var a = document.createElement('a');
                    a.href = url;
                    a.download = ExportType.toLocaleUpperCase() + '.xlsx';
                    a.click();
                    window.URL.revokeObjectURL(url);
                }
            };
            xhr.send(formData);
        }

        /*Echart图*/
        function getRandomColor() {
            var r = Math.floor(Math.random() * 256);
            var g = Math.floor(Math.random() * 256);
            var b = Math.floor(Math.random() * 256);
            return '' + r + ',' + g + ',' + b + '';
        }

        var colors = [
            '0, 0, 255', '255, 165, 0', '255, 255, 0', '128, 0, 128', '0, 255, 255', '255, 0, 255', '0, 128, 0', '255, 192, 203', '255, 69, 0', '255, 20, 147', '0, 255, 127'
        ];
        var GetToDayMachineCapacityChart = function () {
            var chartDom = document.getElementById("Tab1");
            if (chartDom) {
                echarts.dispose(chartDom);
            }
            var myChart = echarts.init(chartDom);
            // 数据
            var data = Tab.Tab1;
            // 更新yAxis的数据
            var yAxisData = data.map(function (item) {
                return item.PROCESS_ID;
            });
            // 更新legend的数据
            var legendData = ['PASS', 'ABORT', 'FAIL'];
            // 更新series的数据
            var seriesData = data.map(function (item) {
                return [item.PASS, item.ABORT, item.FAIL];
            });
            // 更新ECharts配置
            var option = {
                textStyle: {
                    color: '#fff',
                    fontSize: '0.14rem'
                },
                tooltip: {
                    show: true,
                    trigger: 'axis',
                    textStyle: {
                        fontSize: '0.14rem'
                    },
                    axisPointer: {
                        type: 'shadow',
                        crossStyle: {
                            color: 'white'
                        }
                    }
                },
                legend: {
                    show: true,
                    itemWidth: 10,
                    itemHeight: 10,
                    textStyle: {
                        color: '#fff',
                        fontSize: '0.14rem'
                    },
                    data: legendData // 更新legend的数据
                },
                grid: {
                    top: '10%',
                    left: '13%',
                    right:'2%',
                    bottom: '10%',
                    width: '84%',
                },
                xAxis: {
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: true
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#fff',
                            fontSize: '0.14rem'
                        },
                        show: true
                    },
                    splitLine: {
                        show: false
                    }
                },
                yAxis: {
                    type: 'category',
                    data: yAxisData, // 更新yAxis的数据
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#fff',
                            fontSize: '0.12rem',
                            fontWeight: 'bolder',
                        },
                        show: true
                    }
                },
                series: [
                    {
                        name: 'PASS',
                        type: 'bar',
                        stack: 'total',
                        /*barCategoryGap: '50%',*/
                        barGap: '2%',
                        /*barWidth: '60%',*/
                        label: {
                            show: true,
                            color: 'white'
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            normal: {
                                color: '#4f93b2'
                            }
                        },
                        data: seriesData.map(function (item) {
                            return parseInt(item[0]) > 0 ? item[0] : null;
                        }) // 更新DAY_PASS的数据
                    },
                    {
                        name: 'ABORT',
                        type: 'bar',
                        stack: 'total',
                        /*barCategoryGap: '50%',*/
                        barGap: '2%',
                        /*barWidth: '60%',*/
                        label: {
                            show: true,
                            color: 'white'
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            normal: {
                                color: '#f47e56'
                            }
                        },
                        data: seriesData.map(function (item) {
                            return parseInt(item[1]) > 0 ? item[1] : null;
                        }) // 更新DAY_FAIL的数据
                    },
                    {
                        name: 'FAIL',
                        type: 'bar',
                        stack: 'total',
                        /*barCategoryGap: '50%',*/
                        barGap: '2%',
                        /*barWidth: '60%',*/
                        label: {
                            show: true,
                            color: 'white'
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            normal: {
                                color: '#ff5aad'
                            }
                        },
                        data: seriesData.map(function (item) {
                            return parseInt(item[2]) > 0 ? item[2] : null;
                        }) // 更新NIGHT_FAIL的数据
                    }
                ]
            };
            //myChart.setOption(option);
            myChart.setOption(option, false);
            myChart.off('click');
            myChart.on('click', function (params) {
                OperatorHourOutputChart(params.name);
            });
        }

        var OperatorHourOutputChart = function (process_id) {
            $("#operatorhouroutput").remove();
            if (Tab.Tab3.length <= 0) {
                $("#operatorhouroutput").css("display", "none");
                showMessage(`${equipment_name}没有生产数据!`);
                return;
            }
            //$("#operatorhouroutput,#tester_table").empty();
            //数据组装
            var data = Tab.Tab3;
            var result = [];
            $.each(data, function (index, item) {
                if (item.PROCESS_ID === process_id && item.STATE=='Y') {
                    var newItem = {
                        PROCESS_ID: item.PROCESS_ID,
                        TESTER: item.TESTER,
                        DAY: item.DAY,
                        INPUT: item.INPUT,
                        PASS: item.PASS,
                        ABORT: item.ABORT,
                        FAIL: item.FAIL,
                        YIELD: item.YIELD
                    };
                    result.push(newItem);
                }
            });
            var testers = $.map(result, function (item) {
                return item.TESTER;
            });
            // Testers汇总
            var uniqueTesters = $.unique(testers);
            var counttesters = uniqueTesters.length;
            // 动态生成表头
            var headeritme = "";
            var headers = Object.keys(result[0]);
            headers.forEach(function (header) {
                headeritme = headeritme + '<th>' + header + '</th>';
            });
            //生成表体内容
            var sum_input = 0;
            var sum_pass = 0;
            var sum_abort = 0;
            var sum_fail = 0;
            var tabtbody = '';
            result.forEach(function (row, index) {
                index++;
                var tdbody = '';
                headers.forEach(function (header, columnindex) {
                    if (typeof row[header] === "number") {
                        row[header] = row[header].toFixed(0);
                    }
                    if (header === "INPUT") {
                        sum_input = sum_input + parseInt(row[header]);
                    }
                    if (header === "PASS") {
                        sum_pass = sum_pass + parseInt(row[header]);
                    }
                    if (header === "ABORT") {
                        sum_abort = sum_abort + parseInt(row[header]);
                    }
                    if (header === "FAIL") {
                        sum_fail = sum_fail + parseInt(row[header]);
                    }
                    if (header === "YIELD") {
                        row[header] = parseInt(row[header]).toFixed(2) + '%';
                    }
                    tdbody = tdbody + `<td class="truncate ${columnindex < 0 ? "ZebraTo" : null}">${header == "DAY" ? row[header].replace(/\T/g, '&emsp;') : row[header]}</td>`;
                });
                var trbody = `<tr class="${(index % 2) > 0 ? "ZebraNo" : "ZebraTo"}">${tdbody}</tr>`;
                tabtbody = tabtbody + trbody;
            });
            var charthtml = `
            <div id="operatorhouroutput" class="devicedetailt">
	            <div id="tester_table" class="tester_hour" style="color:black;height: 5rem; width: 50%; ">
                    <table id="myTable" class="DataSheet" border="1" style="color:black;width: 100%; height: 100%;">
                        <thead><tr>${headeritme}</tr></thead>
                        <tbody id="yield_tbody">${tabtbody}</tbody>
                        <tfoot><tr><td></td><td>设备数:${counttesters}</td><td></td><td>${sum_input}</td><td>${sum_pass}</td><td>${sum_abort}</td><td>${sum_fail}</td><td>${(sum_input + sum_abort > 0 ? ((sum_pass + sum_abort) / sum_input * 100):0).toFixed(2) + '%' }</td></tr></tfoot>
                    </table>
                </div>
	            <div id="tester_chart" class="tester_hour" style="background-color: #dfe4ee;height: 100%; width: 50%; ">22</div>
            </div>`;
            $("#Tab2").append(charthtml);
            $("#operatorhouroutput").css("display", "block");
            $("#tester_chart").css("color", "black");
            //TesterInputChart
            var TesterInputChart = function () {
                var chartDom = document.getElementById("tester_chart");
                if (chartDom) {
                    echarts.dispose(chartDom);
                }
                var myChart = echarts.init(chartDom);
                var data = Tab.Tab3.filter(function (item) {
                    return item.PROCESS_ID === process_id;
                });
                // 获取所有不重复的tester值
                var tester = Array.from(new Set(data.map(item => item.TESTER)));
                // 获取所有不重复的HOUR值
                var hours = Array.from(new Set(data.map(item => item.HOUR)));
                // 根据tester和HOUR生成series数据
                var seriesData = tester.map(tester => {
                    return {
                        name: tester,
                        type: 'line',
                        data: hours.map(hour => {
                            var item = data.find(d => d.TESTER === tester && d.HOUR === hour);
                            return item ? item.INPUT : null;
                        })
                    };
                });
                var option = {
                    textStyle: {
                        color: 'black',
                        fontSize: '0.16rem'
                    },
                    tooltip: {
                        show: true,
                        trigger: 'axis',
                        textStyle: {
                            fontSize: '0.14rem'
                        },
                        axisPointer: {
                            type: 'cross',
                            crossStyle: {
                                color: 'black'
                            }
                        }
                    },
                    legend: {
                        show: true,
                        width: '100%',
                        type: 'scroll',
                        data: tester,
                        orient: 'horizontal',
                        itemWidth: 10,
                        itemHeight: 10,
                        scrollDataIndex: 0,
                        pageIconSize: [12, 12],
                        pageIconColor: '#666',
                        pageTextStyle: {
                            fontSize: '0.16rem',
                            color: 'black'
                        },
                        textStyle: {
                            color: 'black',
                            fontSize: '0.16rem'
                        }
                    },
                    grid: {
                        top: '10%',
                        left: '5%',
                        right: '1%',
                        bottom: '10%',
                        width: '93%',
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: hours.map(item => item + ':00'),
                        axisLine: {
                            show: false
                        },
                        axisTick: {
                            show: true
                        },
                        axisLabel: {
                            textStyle: {
                                color: 'black',
                                fontSize: '0.14rem'
                            },
                            show: true
                        },
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'value',
                        axisLine: {
                            show: false
                        },
                        axisTick: {
                            show: true
                        },
                        axisLabel: {
                            textStyle: {
                                color: 'black',
                                fontSize: '0.14rem'
                            },
                            show: true
                        },
                        splitLine: {
                            show: false
                        }
                    },
                    series: seriesData.map(function (data, index) {
                        var color = colors[index % colors.length];
                        return {
                            name: data.name,
                            type: 'line',
                            data: data.data,
                            lineStyle: {
                                normal: {
                                    width: 2
                                }
                            },
                            itemStyle: {
                                normal: {
                                    color: 'rgb(' + color + ')'
                                }
                            },
                            areaStyle: {
                                normal: {
                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                        offset: 0,
                                        color: 'rgb(' + color + ',0.2)'
                                    }, {
                                        offset: 0.8,
                                        color: 'rgb(' + color + ',0.1)'
                                    }], false),
                                    shadowColor: 'rgb(' + color + ',0.1)',
                                    shadowBlur: 12
                                }
                            }
                        };
                    })
                };
                myChart.setOption(option);
                window.addEventListener('resize', function () {
                    myChart.resize();
                });
            }
            TesterInputChart();
        }

        var GetCouplingSuccessRateChart = function () {
            var chartDom = document.getElementById("Tab2");
            if (chartDom) {
                echarts.dispose(chartDom);
            }
            var myChart = echarts.init(chartDom);
            // 获取所有不重复的PROCESS值
            var processes = Array.from(new Set(Tab.Tab2.map(item => item.PROCESS_ID)));
            // 获取所有不重复的HOUR值
            var hours = Array.from(new Set(Tab.Tab2.map(item => item.HOUR)));
            // 根据PROCESS和HOUR生成series数据
            var seriesData = processes.map(process => {
                return {
                    name: process,
                    type: 'line',
                    data: hours.map(hour => {
                        var item = Tab.Tab2.find(d => d.PROCESS_ID === process && d.HOUR === hour);
                        return item ? item.INPUT : null;
                    })
                };
            });
            var option = {
                textStyle: {
                    color: '#fff',
                    fontSize: '0.16rem'
                },
                tooltip: {
                    show: true,
                    trigger: 'axis',
                    textStyle: {
                        fontSize: '0.14rem'
                    },
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: 'white'
                        }
                    }
                },
                legend: {
                    show: true,
                    type: 'scroll',
                    width: '100%',
                    data: processes,
                    orient: 'horizontal',
                    itemWidth: 10,
                    itemHeight: 10,
                    scrollDataIndex: 0,
                    pageIconSize: [12, 12],
                    pageIconColor: 'white',
                    pageTextStyle: {
                        fontSize: '0.16rem',
                        color: 'white'
                    },
                    textStyle: {
                        color: '#fff',
                        fontSize: '0.16rem'
                    }
                },
                grid: {
                    top: '10%',
                    left: '3%',
                    right: '1%',
                    bottom: '10%',
                    width: '96%',
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: hours.map(item => item + ':00'),
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: true
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#fff',
                            fontSize: '0.14rem'
                        },
                        show: true
                    },
                    splitLine: {
                        show: false
                    }
                },
                yAxis: {
                    type: 'value',
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: true
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#fff',
                            fontSize: '0.14rem'
                        },
                        show: true
                    },
                    splitLine: {
                        show: false
                    }
                },
                series: seriesData.map(function (data, index) {
                    //var color = getRandomColor();
                    var color = colors[index % colors.length];
                    return {
                        name: data.name,
                        type: 'line',
                        data: data.data,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: 'rgb(' + color + ')'
                            }
                        },
                        /*
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgb(' + color + ',0.2)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgb(' + color + ',0.1)'
                                }], false),
                                shadowColor: 'rgb(' + color + ',0.1)',
                                shadowBlur: 12
                            }
                        }
                        */
                    };
                })
            };
            myChart.setOption(option);
        }

        var GetMachineHourOutputChart = function () {
            var chartDom = document.getElementById("Tab3");
            if (chartDom) {
                echarts.dispose(chartDom);
            }

            var myChart = echarts.init(chartDom);
            // 获取所有不重复的PROCESS值
            var processes = Array.from(new Set(Tab.Tab2.map(item => item.PROCESS_ID)));
            // 获取所有不重复的HOUR值
            var hours = Array.from(new Set(Tab.Tab2.map(item => item.HOUR)));
            // 根据PROCESS和HOUR生成series数据
            var seriesData = processes.map(process => {
                return {
                    name: process,
                    type: 'line',
                    data: hours.map(hour => {
                        var item = Tab.Tab2.find(d => d.PROCESS_ID === process && d.HOUR === hour);
                        return item ? item.YIELD : null;
                    })
                };
            });
            var option = {
                textStyle: {
                    color: '#fff',
                    fontSize: '0.16rem'
                },
                tooltip: {
                    show: true,
                    trigger: 'axis',
                    textStyle: {
                        fontSize: '0.14rem'
                    },
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: 'white'
                        }
                    }
                },
                legend: {
                    show: true,
                    type: 'scroll',
                    width: '100%',
                    data: processes,
                    orient: 'horizontal',
                    itemWidth: 10,
                    itemHeight: 10,
                    scrollDataIndex: 0,
                    pageIconSize: [12, 12],
                    pageIconColor: 'white',
                    pageTextStyle: {
                        fontSize: '0.16rem',
                        color: 'white',
                    },
                    textStyle: {
                        color: 'white',
                        fontSize: '0.16rem'
                    }
                },
                grid: {
                    top: '10%',
                    left: '5%',
                    right: '2%',
                    bottom: '10%',
                    width: '92%',
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: hours.map(item => item + ':00'),
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: true
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#fff',
                            fontSize: '0.14rem'
                        },
                        show: true
                    },
                    splitLine: {
                        show: false
                    }
                },
                yAxis: {
                    type: 'value',
                    min: 0,
                    max: 120,
                    interval: 20,
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: true
                    },
                    axisLabel: {
                        formatter: function (value) {
                            return value + '%';
                        },
                        textStyle: {
                            color: '#fff',
                            fontSize: '0.14rem'
                        },
                        show: true
                    },
                    splitLine: {
                        show: false
                    }
                },
                //series: seriesData
                series: seriesData.map(function (data, index) {
                    //var color = getRandomColor();
                    var color = colors[index % colors.length];
                    return {
                        name: data.name,
                        type: 'line',
                        data: data.data,
                        lineStyle: {
                            normal: {
                                width: 2
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: 'rgb(' + color+')'
                            }
                        },
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgb(' + color + ',0.2)'
                                }, {
                                    offset: 0.8,
                                    color: 'rgb(' + color + ',0.1)'
                                }], false),
                                shadowColor: 'rgb(' + color + ',0.1)',
                                shadowBlur: 12
                            }
                        }
                    };
                })
            };
            myChart.setOption(option);
        }
    </script>
</body>
</html>
